package com.han.swagger2markdown.core.user;

import com.han.swagger2markdown.core.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

@Api("用户相关接口")
@RestController
@RequestMapping("/users")
public class UserController {

    @ApiOperation("新建用户")
    @PostMapping()
    public Result<User> create(@RequestBody UserCreateParam createParam) {
        return Result.success(new User());
    }

    @ApiOperation("批量新建用户")
    @PostMapping("/batch")
    public Result<List<User>> batchCreate(@RequestBody List<UserCreateParam> createParams) {
        return Result.success(new ArrayList<>());
    }

    @ApiOperation("查询用户列表")
    @GetMapping("/list")
    public Result<List<User>> list(@ApiParam("模糊查询") @RequestParam(required = false) String name,
                                   @ApiParam(value = "类型", allowableValues = "standard, custom") @RequestParam(required = false) String type) {
        return Result.success(new ArrayList<>());
    }

    @ApiOperation("查询用户 by id")
    @GetMapping("/{id}")
    public Result<User> queryByOid(@PathVariable Integer id) {
        return Result.success(new User());
    }

    @ApiOperation("更新用户 by id")
    @PutMapping("/{id}")
    public Result<User> updateByOid(@PathVariable Integer id, @RequestBody UserUpdateParam updateParam) {
        return Result.success(new User());
    }

    @ApiOperation("删除用户")
    @DeleteMapping("/{id}")
    public Result<Void> deleteByOid(@PathVariable Integer id) {
        return Result.success();
    }

    @ApiOperation("批量删除用户")
    @DeleteMapping("/batch")
    public Result<Void> batchDeleteByOids(@RequestBody List<String> oids) {
        return Result.success();
    }
}
